package soul.zookeeper;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

/**
 * Created by admin on 2017/1/15.
 */
public class ZooKeeperClient implements Watcher {

    private static final int SESSION_TIME = 2000;
    protected ZooKeeper zooKeeper;
    protected CountDownLatch countDownLatch = new CountDownLatch(1);

    public void connect(String hosts) throws IOException, InterruptedException, IOException {
        zooKeeper = new ZooKeeper(hosts, SESSION_TIME, this);
        countDownLatch.await();
    }

    @Override
    public void process(WatchedEvent watchedEvent) {
        System.out.print("-----");
    }

    public static void main(String[] arg9) throws IOException, InterruptedException {
        ZooKeeperClient client = new ZooKeeperClient();
        client.connect("127.0.0.1");
    }
}
